package com.tensquare.base.dao;

import com.tensquare.base.pojo.Label;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.List;

public interface LabelDao extends JpaRepository<Label,String>,JpaSpecificationExecutor<Label> {
    //自定义 根据 是否 推荐 且 使用次数  查询
    List<Label> findByRecommendOrderByCountDesc(String recommend);

    //添加 关注粉丝 数量
    @Transactional
    @Modifying
    @Query(value = "update tb_label set fans=fans+1 where id=?1",nativeQuery = true)
    void addFans(String id);


}
